<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>班次修改</title>
<jsp:include page="${home}/assets/common_inc_new.jsp"  flush="true"></jsp:include>
<script type="text/javascript" src="${home}/system/common/scripts/utils.js"></script>
<link rel="stylesheet" type="text/css" href="./edit.css">

	<style>
		*{
			font-weight: 400;
		}
		.btn{
			width: 120px;
			height: 40px;
			margin: 0px 40px 0 0;
			border: 1px solid #288ff4;
			color: #288ff4;
			font-size: 16px;
			background-color: #fff;
			border-radius: 5px;
		}

	</style>

</head>

<body class="mainbody">
	<!--导航栏-->
    <div class="location">
        <a onclick="doReturn();" class="back"><i></i><span>返回管理页面</span></a>
        <i class="arrow"></i>
        <span id="lbTitle">班次修改</span>
    </div>

	<%
    	//获得id
    	String editId =request.getParameter("id");
     %>
	<input type="hidden" name="id" id="id" value="<%=editId %>"/>



  <!--<div class="edit-wrap">-->
	<div class="tab-content" style="padding-bottom: 50px;">

		<dl>
            <dt>班次名称：</dt>
            <dd>
                <label id="schedule_name"></label>
            </dd>
        </dl>

		<dl>
            <dt>类别：</dt>
            <dd>
                <label id="schedule_type"></label>
            </dd>
        </dl>

		<dl>
			<dt>工时:</dt>
			<dd>
			  <input class="input normal" type="text" name="man_hour" id="man_hour"  value="">小时/天 
			  <span class="Validform_checktip">*必填</span>    
			</dd>
		</dl>

		<dl>
			<dt>系数:</dt>
			<dd>
			  <input class="input normal" type="text" name="ratio" id="ratio" value="">分 
			  <span class="Validform_checktip">*必填</span>    
			</dd>
		</dl>

		<dl>
			<dt>备注:</dt>
			<dd>
			  <textarea class="input normal" name="remark" id="remark" rows="8"></textarea>
			</dd>
		</dl>
	</div>

    <!--<div class="item">
      <div class="name">
        班次名称:
      </div>
      <div class="value" id="schedule_name">
        正常班
      </div>
    </div>-->
	<!--
    <div class="item">
      <div class="name">
        类别:
      </div>
      <div class="value" id="schedule_type">
        周一至周五法定工作日值班
      </div>
    </div>
	-->
    <!--<div class="item">
      <div class="name">
        <span style="color:#FF0000;">*</span>工时:
      </div>
      <div class="value">
        <input class="edit-input" type="text" name="man_hour" id="man_hour"  value="">小时/天
      </div>
    </div>
    <div class="item">
      <div class="name">
        <span style="color:#FF0000;">*</span>系数:
      </div>
      <div class="value">
        <input class="edit-input" type="text" name="ratio" id="ratio" value="">分
      </div>
    </div>

    <div class="item">
      <div class="name">
        <div class="remark">
          备注:
        </div>
      </div>
      <div class="value">
        <textarea class="edit-input" name="remark" id="remark" rows="8"></textarea>
      </div>
    </div>-->

	

    <div class="actions">
		<input type="button" id="btnCancel" name="btnCancel" value="取消" class="btn" onclick="cancel();" />
		<input type="button" id="btnSave" name="btnSave" value="保存" class="btn" onclick="edit();" />
      <!--<button class="action" type="button" onclick="cancel()">取消</button>
      <button class="action" type="button" onclick="edit()">保存</button>-->
    </div>
  <!--</div>-->



<script type="text/javascript">
	$(document).ready(function () {
			getDetailInfo();
	})

	function doReturn(){
	   window.history.back(-1);
	   parent.diag.close();
    }


	function back() {
	  window.location.href = "index.jsp";
	}

	function cancel() {
	  back();
	}

	//点击保存后，执行修改班次配置的操作
    function edit() {
       var head = {	
			"service_name": "cn.dy.workatten.service.ScheduleCfgService",
			"operation_name": "updateScheduleCfg"
		}
		
		var param = {
			"scheduleCfg": {
			"id":$("#id").val(),
			"man_hour":$("#man_hour").val(),
			"ratio":$("#ratio").val(),
			"remark":$("#remark").val()
			}
		}
		var options = {
			"handleError": false,
			"showProgressBar":false,
			"timeout":60000*10
		}
		
		var myCallback=function callBack(data) {
			if(data.response_code==0){
				alert(data.response_desc);
				back();
			}else{
				alert(data.response_detail);
			}				
		}		
		$.ServiceAgent.JSONInvoke(head, param, myCallback, options);
    }


	// 获得班次信息
    function getDetailInfo() {
       var head = {	
			"service_name": "cn.dy.workatten.service.ScheduleCfgService",
			"operation_name": "getScheduleCfgById"
		}
		
		var param = {
			"id":$("#id").val(),
		}
		var options = {
			"handleError": false,
			"showProgressBar":false,
			"timeout":60000*10
		}
		
		var myCallback=function callBack(data) {
			if(data.response_code==0){
				var oneDetail = data.content.result;
				$("#man_hour").val(oneDetail.man_hour);
				$("#ratio").val(oneDetail.ratio);
				$("#remark").val(oneDetail.remark);

				var schType = "";
				if(oneDetail.schedule_type == "0"){
					schType = "工作日";
				} else if (oneDetail.schedule_type == "1") {
					schType = "连假周末";
				} else if (oneDetail.schedule_type == "2") {
					schType = "法定节假日";
				} else if (oneDetail.schedule_type == "3") {
					schType = "春节";
				} else if (oneDetail.schedule_type == "4") {
					schType = "周末";
				}

				$("#schedule_type").html(schType);
				$("#schedule_name").html(oneDetail.schedule_name);
				
			}else{
				alert(data.response_detail);
			}				
		}		
		$.ServiceAgent.JSONInvoke(head, param, myCallback, options);
    }

</script>


</body>
</html>
